<div id="page">
	<h3>Create adverts</h3>
	<p class="bold">Dados do novo anuncio</p>
	<form action="<?= $html->url('/pbanner/pbanner_adverts/add_advert'); ?>" method="post" enctype="application/x-www-form-urlencoded">
		<p>
			<label for="Identifier">Identifier:</label><br />
			<?= $form->text('PbannerAdvert.identifier', array('class' => 'big')); ?>
		</p>
		<p>
			<label for="description">Description:</label><br />
			<?= $form->text('PbannerAdvert.description', array('class' => 'big')); ?>
		</p>
		<p>
			<label for="description">Expiration date:</label><br />
			<?= $form->text('PbannerAdvert.expiration'); ?>
		</p>
		<div class="clear"></div>
		<p>
			<?= $form->submit('Save', array('class' => 'button')); ?>
		</p>
	</form>
	<table>
		<caption class="left">Anuncios disponiveis</caption>
		<thead>
			<tr>
				<th>Adverts</th>
				<th>Description</th>
				<th>Data created</th>
				<th>Data Expirated</th>
				<th>Option</th>
			</tr>
		</thead>
		<tbody>
			<?php
				foreach($adverts as $advert){
					echo '<tr>';
						echo '<td>' . $advert['PbannerAdvert']['identifier'] . '</td>';
						echo '<td>' . $advert['PbannerAdvert']['description'] . '</td>';
						echo '<td>' . str_replace('-', '/',$advert['PbannerAdvert']['created']) . '</td>';
						if($advert['PbannerAdvert']['expiration'] === '0000-00-00')
							echo '<td>not expirated</td>';
						else
							echo '<td>' . str_replace('-', '/',$advert['PbannerAdvert']['expiration']) . '</td>';
						echo '<td>';
							echo ($advert['PbannerAdvert']['active']) ? $html->link($html->image('/pbanner/img/status_ativo.gif'), array('plugin' => 'pbanner', 'controller' => 'pbanner_adverts', 'action' => 'mode_status', 'id' => $advert['PbannerAdvert']['id']), array(), false, false) : $html->link($html->image('/pbanner/img/status_inativo.gif'), array('plugin' => 'pbanner', 'controller' => 'pbanner_adverts', 'action' => 'mode_status', 'id' => $advert['PbannerAdvert']['id']), array(), false, false);
							echo $html->link($html->image('/pbanner/img/excluir.gif'), array('plugin' => 'pbanner', 'controller' => 'pbanner_adverts', 'action' => 'delete', 'id' => $advert['PbannerAdvert']['id']), array(), 'Tem certeza que deseja excluir?', false);
							echo $html->link($html->image('/pbanner/img/editar.gif'), array('plugin' => 'pbanner', 'controller' => 'pbanner_adverts', 'action' => 'edit', 'id' => $advert['PbannerAdvert']['id']), array(), false, false);
						echo '</td>';
					echo '<tr>';
				}
			?>
		</tbody>
	</table>
</div>
<div id="sidebar">
	<h4>About</h4>
	<p>Pequeno relatório do funcionamento do PBanner.</p>
	<?= $this->renderElement('menu', $menu); ?>
	<?= $this->renderElement('links'); ?>
</div>
<?= $this->renderElement('footer'); ?>
<script type="text/javascript">
	Date.format = 'yyyy-mm-dd';
	$(function(){
		$('#PbannerAdvertExpiration').datePicker({clickInput:true})
	});
</script>